package com.base.myproject.client.ui;

import com.extjs.gxt.ui.client.widget.TabPanel;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;

public class BaseTabPanel extends TabPanel {
	static BaseTabPanel advanced = null;
	

	private BaseTabPanel() {
	//	setSize(800, 600);
		
		setMinTabWidth(115);
		setResizeTabs(true);
		setAnimScroll(true);
		setTabScroll(true);
	
		setHeight(Window.getClientHeight()-84);
		setWidth(Window.getClientWidth()-8);
		}
	/****
	 * 重载此方法 用于加载新的css
	 * @param i
	 * @return
	 */
	public static BaseTabPanel getInstance(int i)
	{
		if(advanced==null)
			advanced = new BaseTabPanel();
		advanced.setPlain(true);
		advanced.setStyleName("no_bg_tab_panel");
		return advanced;
	}
	public static BaseTabPanel getInstance()
	{
		if(advanced==null)
		{
			advanced = new BaseTabPanel();
			advanced.setBorders(false);
			advanced.setBodyBorder(false);
			advanced.setPlain(true);
			
		}
		return advanced;
	}
	protected void onRender(Element target, int index) {
		super.onRender(target, index);
		//getLayoutTarget().setStyleAttribute("background-image", "none");
		//getLayoutTarget().setStyleAttribute("background", "url(../images/bgimg/base_bg_img.jpg)");
		//getLayoutTarget().setStyleAttribute("background-image", "url(images/baseimage/backgroup/logo.png)");
		//getLayoutTarget().setStyleAttribute("background-repeat", "no-repeat");
		//getLayoutTarget().setStyleAttribute("background-position", "center");
		//getLayoutTarget().setStyleAttribute("background-color", "#CCD9E8");
		getLayoutTarget().setStyleAttribute("height", "100%");
		getLayoutTarget().setStyleAttribute("width", "100%");
	}
	public void addTab(String name,Widget widget) {
		BaseTabItem item = new BaseTabItem();
	
		item.setText(name);
		
		item.setClosable(true);
		item.setWidth(100);
		//item.addText("Tab Body " + index);
		
		item.add(widget);
		
		// item.addStyleName("pad-text");
		advanced.add(item);
		advanced.setSelection(item);

	}

}
